function c = corrcoef(u,v)

u = u(:);
v = v(:);
N = length(u);

u = u - nanmean(u);
v = v - nanmean(v);

c = (nansum(u .* v) / (N-1)) / (nanstd(u) * nanstd(v));

